package com.taoding.controller.core;


import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.taoding.commons.BaseController;
import com.taoding.entity.core.AccountBookRelation;
import com.taoding.service.core.AccountBookRelationService;
import com.taoding.vo.core.AccountBookRelationPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 木牛盒子客户关联 前端控制器
 * </p>
 *
 * @author lxh123
 * @since 2019-12-05
 */
@RestController
@RequestMapping("/server/accountBookRelation")
@Api(value = "/server/accountBookRelation",description = "木牛盒子客户关联")
public class AccountBookRelationController extends BaseController {

    @Autowired
    private AccountBookRelationService accountBookRelationService;


    @PostMapping("/add")
    @ApiOperation(value = "添加",notes = "")
    public Object add(@RequestBody AccountBookRelation vo){
        vo.setId(String.valueOf(IdWorker.getId()));
        boolean insert = accountBookRelationService.save(vo);
        if (insert){
            return success("新增成功！");
        }
        return error("新增失败！");
    }

    /**
     * 多表分页查询
     * @param vo
     * @return
     */
    @PostMapping("/selectPage")
    @ApiOperation(value = "查询详情分页",notes = "根据条件查询分页")
    public Object selectPage(@RequestBody AccountBookRelationPageVO vo){
       return success(accountBookRelationService.selectDetailPage(vo));
    }

    /**
     * 单表分页查询
     * @param vo
     * @return
     */
    @PostMapping("/selectPage2")
    @ApiOperation(value = "单表分页查询",notes = "根据条件查询分页")
    public Object selectPage2(@RequestBody AccountBookRelationPageVO vo){

        return success(accountBookRelationService.selectDetailPage2(vo));
    }


}

